package com.horizon.cloud.standard.hibernate;

import com.horizon.cloud.common.distribute.idGenerator.IdGenerator;
import com.horizon.cloud.distribute.IdGenerator.impl.SnowflakeIdGenerator;

import java.util.Map;

public class SnowflakeIdGeneratorFactory {
    private Map<String, SnowflakeIdGenerator> generatorMap;

    public synchronized SnowflakeIdGenerator getIdGenerator(String type) {
        if (generatorMap.containsKey(type)) {
            return generatorMap.get(type);
        }
        SnowflakeIdGenerator snowflakeIdGenerator = new SnowflakeIdGenerator(type);
        generatorMap.put(type, snowflakeIdGenerator);
        return snowflakeIdGenerator;
    }
}
